<?php
/**
 * Created by PhpStorm.
 * User: tairy
 * Date: 05/06/2018
 * Time: 14:28
 */

namespace Core\Common\Model;

use Core\Common\Route\Request;
use Illuminate\Database\Eloquent\Model as Eloquent;

class BaseModel extends Eloquent
{
    // 是否启用表名 mock
    protected $enableMockTable = false;

    /**
     * Get the table associated with the model.
     *
     * @return string
     */
    public function getTable()
    {
        $tbl = parent::getTable();

        // 在压测环境下，如果有开启影子表，则改表名
        if ($this->enableMockTable && !empty($tbl) && Request::isRunningInMars()) {
            return $tbl . "_mars";
        }

        return $tbl;
    }
}
